package 算法类;

/**
 * @author lee
 * @date 2021年07月16日 16:29
 */

import java.util.Arrays;

public class 两数之和{
    public static void main(String[] args) {
        Solution solution = new 两数之和().new Solution();
        int[] num =  {2,7,11,15};
        int target = 9 ;
        int[] a = solution.twoSum(num, target);
        System.out.println(Arrays.toString(a));
    }
    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int[] twoSum(int[] nums, int target) {
            int[] a = new int[2];
            for(int i = 0;i<nums.length;i++){
                for(int y = (i+1);y<nums.length;y++){
                    if(target == (nums[i]+nums[y])){
                        a[0]=i;
                        a[1]=y;
                    }
                }
            }

            return a;
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}